import pcsMixin from '@/base/mixin/cgabunits';
// 行政区划，因多个页面需要选择行政区划，数据统一从这引用
export default {
  mixins: [pcsMixin],
  data() {
    return {
      mix_xzqhList: [
        {
          code: '350213',
          note: '翔安区',
          py: 'FJXMSXAQ',
          children: []
        },
        {
          note: '思明区',
          code: '350203',
          py: 'FJXMSSMQ',
          children: []
        },
        {
          note: '海沧区',
          code: '350205',
          py: 'FJXMSHCQ',
          children: []
        },
        {
          note: '湖里区',
          code: '350206',
          py: 'FJXMSHLQ',
          children: []
        },
        {
          note: '集美区',
          code: '350211',
          py: 'FJXMSJMQ',
          children: []
        },
        {
          note: '同安区',
          code: '350212',
          py: 'FJXMSTAQ',
          children: []
        }
      ],
      mix_xzqhMap: {
        '350213': 0,
        '350203': 1,
        '350205': 2,
        '350206': 3,
        '350211': 4,
        '350212': 5
      },
      mix_propMap: { label: 'note', value: 'code', children: 'children' }
    };
  },
  methods: {
      mix_getPcs() {
        if (this.mix_xzqhList[0].children.length === 0) {
            this.getPcsList({}).then(res => {
              res.forEach(r => {
                let parentCode = r.code.slice(0, 6);
                if(this.mix_xzqhMap[parentCode] !== undefined) {
                  this.mix_xzqhList[this.mix_xzqhMap[parentCode]].children.push(r);
                } else {
                console.log(r.code + '不存在父级区')
                }
              })
            });
          }
      }
  }
};
